package com.darly.dlndk.controller;

import android.util.Log;

import com.darly.dlndk.module.lame.AudioRecorder;
import com.darly.dlndk.module.thread.CThreadConfig;
import com.darly.dlndk.module.thread.CThreadRunListener;
import com.darly.dlndk.module.FirstNdkListener;
import com.darly.dlndk.module.FirstNdkModule;

/**
 * Description TODO: 整体统领NDK管理类
 * Package com.darly.dlndk.controller
 * Author fronchdarly
 * Date 2021/2/26 2:16 PM

 */
public class NDKController {

    private NDKController() {
    }

    static class NDKControllerHolder {
        static NDKController controller = new NDKController();
    }

    public static NDKController getInstance() {
        return NDKControllerHolder.controller;
    }

    /**
     * 初始化测试类库
     */
    public void init(){
        Log.d("NDKController", "init: "+FirstNdkModule.getInstance().stringFromJNI());
        FirstNdkModule.getInstance().registerListener(new FirstNdkListener() {
            @Override
            public void showLog(int level, String msg) {
                Log.d("NDKController", "registerListener: "+level+"<----->"+msg);
            }
        });
        Log.d("NDKController", "registerListener: 注册监听");
        FirstNdkModule.getInstance().init("aaaaaaaaaaaaaaa");
        Log.d("NDKController", "init: 开始初始化");
        boolean encrypt = FirstNdkModule.getInstance().fileEncrypt("","");
        Log.d("NDKController", "fileEncrypt: 压缩"+ encrypt);

        FirstNdkModule.getInstance().registerCThread(new CThreadRunListener() {
            @Override
            public void receive(int level, String json) {
                Log.d("NDKController", "registerCThread: "+ json);

                AudioRecorder.init(AudioRecorder.DEFAULT_SAMPLING_RATE, AudioRecorder.DEFAULT_LAME_IN_CHANNEL, AudioRecorder.DEFAULT_SAMPLING_RATE,
                        AudioRecorder.DEFAULT_LAME_MP3_BIT_RATE,AudioRecorder. DEFAULT_LAME_MP3_QUALITY);
            }
        }, CThreadConfig._default_size,CThreadConfig.C_T_TIME);
    }
}
